#include "shell.h"
#include "ringbuffer8.h"
#include "debug.h"
#include "board.h"
#include "dht11.h"
#include "FreeRTOS.h"
#include "task.h"

/* DHT11参数结构体 */
struct dht11 ws_dht;
DHT11_t WS_DHT = &ws_dht;

bool shell_getdht(void)
{
    return dht_receive_data(WS_DHT);
}

void dht11_task(void* param)
{
    int check = 1;
    
    taskENTER_CRITICAL();
        check = dht11_init(WS_DHT,DHT11_PORT,DHT11_PIN);        //保护dht11初始化不被打断
    taskEXIT_CRITICAL();
    MyASSERT(!check,"task_ame:DHT11,There's no response\r\n");
    while (1)
    {
        dht_receive_data(WS_DHT);
        xQueueSend(extern_to_oled_queue, &WS_DHT->humidity, pdMS_TO_TICKS(100));
        xQueueSend(extern_to_oled_queue, &WS_DHT->temperature, pdMS_TO_TICKS(100));
        vTaskDelay(500);
    }
}
